AddLabor = {
	saveConfig:function (){
		var id = document.getElementById("projectNameId").value;
		var projectProcess = document.getElementById("projectProcess").value;
		var datetime=document.getElementById("datetime").value;
		var hours=document.getElementById("hours").value;
		var locale=document.getElementsByName("locale");
		var section=document.getElementById("addSection").value;
		var descr=document.getElementById("descr").value;
		if(id==''){
		    PigossMsg.alert("没有项目，要先添加项目，之后才能添加工时!");
		    return;
		}
		if(datetime==''){
		   PigossMsg.alert("工时不能为空！");
		   return;
		}
		if(hours==''){
		   PigossMsg.alert("时间不能为空！");
		   return;
		}
		if(descr==''){
			   PigossMsg.alert("工作内容不能为空！");
			   return;
			}
		if(!parseFloat(hours)){
		    PigossMsg.alert("时间输入必须为数字！");
		    return;
		}
		var isLocale="";
		for(var i=0;i<locale.length;i++){
		    if(locale.item(i).checked){
            isLocale=locale.item(i).getAttribute("value");  
		   }
		}
		AjaxUtil.request({
			url : 'add_labor.action',
			params : {id:id,projectProcess:projectProcess,datetime:datetime,hours:hours,isLocale:isLocale,section:section,descr:descr},
			success : function(responseText){
				Refreshh.refresh();
			},
			failure : function(){
				PigossMsg.alert("添加失败!");
			}
		});
		imgCloseShow();
	}
};
Refreshh= {
   refresh:function(){
       document.getElementById("query_labor_by_condition").submit();
   }
};
EditLabor= {
    editConfig:function (){
    	var lid = document.getElementById("editLid").value;
		var pid = document.getElementById("editProjectNameId").value;
		var projectProcess = document.getElementById("editProjectProcess").value;
		var section=document.getElementById("editSection").value;
		var datetime=document.getElementById("editDatetime").value;
		var locale=document.getElementsByName("editLocale");
		var hours=document.getElementById("editHours").value;
		var descr=document.getElementById("editDescr").value;
		
		
		if(datetime==''){
		   PigossMsg.alert("工时不能为空！");
		   return;
		}
		if(hours==''){
		   PigossMsg.alert("时间不能为空！");
		   return;
		}
		if(!parseFloat(hours)){
		    PigossMsg.alert("时间输入必须为数字！");
		    return;
		}
		var locales = "";
		for(var i=0;i<locale.length;i++){
		    if(locale.item(i).checked){
		    	locales = locale.item(i).getAttribute("value");  
		   }
		}
		AjaxUtil.request({
			url : 'edit_labor.action',
			params : {lid:lid,pid:pid,projectProcess:projectProcess,section:section,datetime:datetime,hours:hours,locales:locales,descr:descr},
			success : function(responseText){
				//window.location.reload();
				Refreshh.refresh();
			},
			failure : function(){
				 PigossMsg.alert("修改失败!");
			}
		});
		imgCloseShow();
	},
	
	del:function (id){
    AjaxUtil.request({
		url : 'delete_labor.action',
		params : {id:id},
		success : function(responseText){
			Refreshh.refresh();
		},
		failure : function(){
			PigossMsg.alert("删除失败!");
		}
	});
   }
	
};

